Skip to main content

Splitting events into multiple streams

4 Tasks

20 mins

Pega Platform
Visible to: All users
Beginner Pega Platform English

Scenario

In the Sample application, the Sample-Data-SplitJoin Class is created for the exercise. The Class uses the following data structure:

Field Type Description

EventID

Identifier

A unique identifier for every incoming record.

EventKey

Text

A key field that is used to group the incoming events.

Channel

Text

The channel name that created the event. (Web, Mobile)

Value

Integer

A field that can hold integer values.

Create two Event Strategies in the Sample-Data-SplitJoin Class to experiment with the Split and Split Join components.

Use case 1: Create an Event Strategy that Splits the stream into two paths.

Use case 2: Create an Event Strategy that can compare the current Value with the average Value of the last three events.

Use the following credentials to log in to the exercise system:

Role User name Password
System architect SystemArchitect rules

Your assignment consists of the following tasks:

Task 1: Splitting events into multiple streams.

Create a new Event Strategy in the Sample-Data-SplitJoin Class with the name Split Events.

Configure the Event Strategy:

  1. Use the EventKey field as the Event key and System time as the Event timestamp.
  2. Add a split component.
  3. Add a filter component named "Web Events" that filters events with the Channel field equal to Web.
  4. Add a filter component named "Mobile Events" that filters events with the Channel field equal to Mobile.

Task 2: Test the Split Events Event Strategy

Test the behavior of the Split component.

Scenario 1: Send an event for any Event Key where the Channel is Web.

Scenario 2: Send an event for any Event Key where the Channel is Mobile.

Confirm the events take the correct path by confirming the EventType value for each scenario.

Task 3: Detecting a trend with the Split Join component

Create a new Event Strategy in the Sample-Data- SplitJoin Class, named Split Join Events.

Configure the Event Strategy:

  1. Use the EventKey field as the Event key and System time as the Event timestamp.
  2. Add a Split Join component.
  3. On the primary path add a Sliding Window that looks at the last event.
  4. On the secondary path add another sliding window that looks at the last three events.
  5. On the secondary path, after the Sliding Window, add an Aggregation component that calculates:
    1. Counts the number of events as NumberOfEventsTemp.
    2. Calculates the average Value as AverageValueTemp.
  6. In the join component, map the NumberOfEventsTemp as NumberOfEvents and AverageValueTemp as AverageValue.

Task 4: Test the Split Join Events Event Strategy

Test the behavior of the Event Strategy with the Split Join component.

Test Scenario 1: Send a single event for any Event Key using the following values:

  • Event 1 with Value = 10
  • Event 2 with Value = 20
  • Event 3 with Value = 30

Confirm that the aggregations in the split path are calculated and joined to the main path, emitting a single event with the calculated values.

 

You must initiate your own Pega instance to complete this Challenge.

Initialization may take up to 5 minutes so please be patient.

Challenge Walkthrough

Detailed Tasks

1 Splitting events into multiple streams

  1. Log in as the system architect:
    1. In the User name field, enter SystemArchitect.
    2. In the Password field, enter rules.
  2. In the navigation pane of Dev Studio, click App to open the Application Explorer.
  3. In the Application Explorer, search for the Sample-Data-SplitJoin Class.
  4. In the Application Explorer, right-click the Sample-Data-SplitJoin Class, then select Create > Decision> Event Strategy.
  5. On the Create Event Strategy tab, create a new Event Strategy:
    1. In the Label field, enter Split Events.
    2. In the upper-right corner, click Create and open.
      Create and open
  6. On the Edit Event Strategy: Split Events rule form, double-click the Real-time data component to set up the Real-time data properties.
    1. In the Event key list, select EventKey.
    2. In the Event timestamp, confirm that System time is selected.
    3. Click Submit.
      submit
  7. On the canvas, on the Real-time data component, click Add > Split to add a new path.
    Tip: The connector that radiates from the Split shape always leads to the Emit shape. This means that the events from each path in the Event Strategy are not combined before being emitted.
  1. On the canvas, click the arrow radiating right of the split component, then select Filter to add a Filter component to the primary path.
    Filter
  2. On the canvas, double-click the Filter component to set up the Filter properties.
    1. In the Name field, enter Web Events.
    2. In the Filter conditions section, click the Add condition to define a new condition.
    3. In the Field column, enter or select Channel.
    4. In the Operator list, select =.
    5. In the Expression column, enter "Web".
    6. Click Submit.
      submit 2
  3. On the canvas, click the arrow radiating towards the Emit component, then select Filter to add a filter component to the secondary path.
    flow 2
  4. On the canvas, double-click the Filter component to set up the Filter properties.
    1. In the Name field, enter Mobile Events.
    2. In the Filter conditions section, click the Add condition to define a new condition.
    3. In the Field column, enter or select Channel.
    4. In the Operator list, select =.
    5. In the Expression column, enter "Mobile".
    6. Click Submit to close the dialog box.
      submit 3
  5. On the Event Strategy: Split Events rule form, in the upper-right corner, click Save.

2 Test the Split Events Event Strategy

  1. In the upper-right corner, click Actions > Run to open the run window.
  2. In the Run window, complete the following settings:
    1. In the EventKey field, enter any value, for example, Key-1.
    2. In the Channel field, enter Web.
    3. In the upper-right corner, click Run to send a single event to the Event Strategy.
      run
  3. Analyze the results:
    1. The Sent events (1) section now has a single page.
    2. The Emitted events (1) section currently has one event emitted. This event passed through the Web Filter and the event is emitted as it happened.
    3. In the Emitted events (1) section, the EventType field is set to Web Events. This is the name of the last component that was used before the event was emitted. The Event Type is available in the output so that further processing can be applied within the Data Flows that use the Event Strategy.
      Event Strategy
  4. In the Run window, click Clear events to start a new test case with the following settings:
    1. In the EventKey field, enter any value, for example, Key-2.
    2. In the Channel field, Mobile.
    3. In the upper-right corner, click Run only once to send a single event to the Event Strategy.
  5. Analyze the results:
    1. The Sent events (1) section now has a single page.
    2. The Emitted events (1) section currently has one event emitted. This is an event passed through the Mobile Filter and the event is emitted as it happened.
    3. In the Emitted events (1) section, the EventType field is set to Mobile Events. This is the name of the last component that was used before the event was emitted.
      Event Strategy 2

3 Detecting a trend with the Split Join

  1. In the Application Explorer, right-click on the Sample-Data-SplitJoin class, then select Create > Decision> Event Strategy.
  2. On the Create Event Strategy tab, create a new Event Strategy:
    1. In the Label field, enter Split Join Events.
    2. In the upper-right corner, click Create and open.
  3. On the Edit Event Strategy: Split Join Events rule form, set up the Event Strategy.
  4. On the canvas, double-click on Real-time data component to set up the Real-time data properties.
    1. In the Event key list, select EventKey.
    2. In the Event timestamp, confirm that System time is selected.
    3. Click Submit.
  5. On the canvas, on the Real-time data component, click Add > Split and Join to add a new path.
    Tip: The connector that radiates from the split shape now leads to the Join shape. The join logic is configured in the Join shape on the basis of a when condition, where one property from the primary path equals another property from the secondary path. Every join logic can have multiple join conditions.
  1. On the canvas, click the arrow radiating right of the split component, then select Window to add a new window component to the primary path.
    flow 3
  2. On the canvas, double-click on Window component to set up the Window properties.
    1. In the Name field, enter Last Event.
    2. In the Window field, select Sliding.
    3. In the Look for last field, enter 1 and select Events.
    4. Click Submit.
      Submit5
  3. On the canvas, click the arrow radiating towards the second path, then select Window to add a window component to the secondary path.
  4. On the canvas, double-click on Window component to set up the Window properties.
    1. In the Name field, enter Last Three Events.
    2. In the Window field, select Sliding.
    3. In the Look for last field, enter 3 and select Events.
    4. Click Submit.
      Submit 6
  5. On the canvas, on the Last Three Events window component, click Add > Aggregate to add a new aggregate component.
  6. On the canvas, double-click on Aggregate component to set up the Aggregate properties.
    1. Click Add aggregation to define a new variable.
      1. In the first column, select Count,
      2. In the Aggregate column enter NumberOfEventsTemp.
    2. Click Add aggregation to define a new variable.
      1. In the first column, select Average,
      2. In the Source column enter or select Value.
      3. In the Aggregate column enter AverageValueTemp.
        Aggregate
      4. Click Submit.
        Tip: You will use the NumberOfEventsTemp and AverageValueTemp variables in the Join step. The variable names defined in the Event Strategy must be unique. When you join events, the property values from events that are on the primary path always take precedence over the property values from events that are on the secondary path. To preserve property values from the secondary path, you can create additional properties for storing those values.
  1. On the canvas, double-click on Join component to set up the Join properties.
    Note: By default, the join condition is made on the EventKey.
    1. In the Output section, click Add Field.
    2. In the first list, select NumberOfEventsTemp.
    3. In the last field, enter NumberOfEvents.
    4. In the Output section, click Add Field.
    5. In the first list, select AverageValueTemp.
    6. In the last field, enter AverageValue.
    7. Click Submit.
      submit 6
  2. In the upper-right corner, click Save.
    save 3

4 Test the Split Join Events Event Strategy

  1. On the Event Strategy: Split Join Events rule form, in the upper-right corner, click Actions > Run to open the run window.
  2. In the Run window, complete the following settings:
    1. In the EventKey field, enter any value, for example, Key-2.
    2. In the Value field, enter 10.
    3. In the upper-right corner, click Run to send a single event to the Event Strategy.
      run 3
  3. Analyze the results:
    1. The Sent events (1) section now has a single page.
    2. The Emitted events (1) section currently has one event emitted.
    3. The primary path sets the Value. The Value from the primary path always overrides the Value from the secondary path. NumberOfEvents calculated in the secondary path is currently 1 and the AverageValue is equal to the Value, 10 because there is only a single event in the window.
      run 4
  4. In the Value field, enter 20, and then click Run to send a second event to the Event Strategy.
  5. Analyze the results:
    1. The Sent events (2) section now has a second page.
    2. The Emitted events (2) section now has a second event emitted.
    3. The Value from the primary path is 20. The NumberOfEvents counted on the secondary path is currently 2 and the AverageValue is equal to 15 ((10+20) / 2). This is because the window is looking at the last two events.
      run 5
  6. In the Value field, enter 30, and then click Run to send a second event to the Event Strategy.
  7. Analyze the results:
    1. The Sent events (3) section now has a third page.
    2. The Emitted events (3) section now has a third event emitted.
    3. The Value from the primary path is 30. NumberOfEvents counted on the secondary path is currently 3 and the AverageValue is equal to 20. ((10+20+30) / 3). This is because the window is looking at the last three events.
      input events 2


Available in the following mission:

If you are having problems with your training, please review the Pega Academy Support FAQs.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice